#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

int binarySearch(int p[], int key, int n)
{
	int left = 0;
	int right = n - 1;
	int count = 0;
	while (left <= right)
	{
		int mid = (left + right) / 2;
		count++;
		if(p[mid] == key)
		{
			return mid;
		}
		else if(p[mid] > key)
		{
			right = mid - 1;
		}
		else
		{
			left = mid + 1;
		}
	}
	printf("%d\n", count);
	return -1;
}


int main()
{
	int arr[] = { 12,18,24,35,47,50,60,83,90,105,134 };
	int key = 100;
	int right = sizeof(arr) / sizeof(arr[0]);
	int ret = binarySearch(arr, key, right);
	if (ret == -1)
		printf("%d", ret);
	else
		printf("%d\n", arr[ret]);
	return 0;
}